from Crypto.Cipher import PKCS1_v1_5 #用于RSA加密
from Crypto.PublicKey import RSA#用于导入公钥
import base64
info = "我爱离散数学"
with open('public_key.txt',mode='r',encoding='utf-8') as f:
    public_key = RSA.import_key(f.read())#把公钥字符串转换为public_key
rsa = PKCS1_v1_5.new(public_key)#创建加密对象
info_rsa_b = rsa.encrypt(info.encode('utf-8'))#RSA加密
info_rsa_s = base64.b64encode(info_rsa_b).decode('utf-8')#base64编码
info_rsa_s